package top.jsnow;

import top.jsnow.Jsnow;
import top.jsnow.controller.Controller;
import top.jsnow.controller.annotation.Action;
import top.jsnow.controller.annotation.GetAction;
import top.jsnow.controller.annotation.PostAction;
import top.jsnow.http.Session;

import java.util.HashMap;
import java.util.Map;

public class App extends Controller {

    @GetAction("/test")
    public String test(String a,String b){
        Session session = req.session();
        String index = (String)session.get("index");
        if (index==null){
            index = "0";
        }
        index = Integer.valueOf(index)+1+"";
        session.put("index",index);
        Map<String, String> cookie = new HashMap<>();
        cookie.put("ID","123");
        cookie.put("Name", "ZhangSan");
        resp.addCookie(cookie);

        return "a:"+a+"\nb:"+b+"\nindex:"+index;
    }

    @PostAction("/test")
    public void test1(){

    }
    @Action("/test2")
    public void test2(){

    }

    public static void main(String[] args) throws Exception {
        Jsnow.start();
    }
}
